package Pro;

import java.util.Hashtable;

public class MyFruitStore02 {
    private static Hashtable<Integer,MyFruit> Fruittable = null;
    private static MyFruitStore02 fruitStore02 = null;

    private MyFruitStore02() {
        Fruittable = new Hashtable<>();
    }
    public static MyFruitStore02 getfruitstore(){
        if(fruitStore02 == null){
            fruitStore02 = new MyFruitStore02();

        }
        return fruitStore02;

    }
    public void Add(Integer key, MyFruit fruit){
        Fruittable.put(key,fruit);     //通过货架号添加水果
    }
    public MyFruit Get(Integer key) throws CloneNotSupportedException {
        MyFruit fruit = Fruittable.get(key);
        return (MyFruit) fruit.clone();
    }
}
